import { createApp } from 'vue';
import index from './index.vue';

/**
 * 确认
 * @param content 
 * @param title 
 */
export default (content: string, title?: string) => {
    return new Promise((resolve, reject) => {
        const dom = document.createElement('div');
        const app = createApp(index, {
            content,
            title,
            cancel: () => {
                reject();
            },
            ok: () => {
                resolve(() => {
                    //@ts-ignore
                    app._instance.setupState.visible = false;
                });
            }
        });
        app.mount(dom);
        document.body.appendChild(dom);
    });
}